	var path = window.location.href;
	var id = path.substring(path.indexOf("=") + 1);
	var token=localStorage.getItem("key");
	console.log(token);
	//商品详情
	$.ajax({
		type: "get",
		url: "/api/meetingroom/goodsDetail",
		async: true,
		data: {"token":token,"goodsId": id},
		dataType: "json",
		success: function(data) {
			var list = data.data;
			console.log(list);
			$('.tb-detail-hd h1').html(list.goodsname);
			$('.tb-detail-hd span').html(list.goodsInfo);
			$('.sys_item_price').html('<span id="price">'+list.goodPrice+'</span><span>可得' + list.pointBuyAmount + '积分</span>');
			$('.addr').html('从' + list.city + '发货，并提供售后服务');
			$('.monthSales').html(list.monthSales);
			$('.stock').html(list.stock);
			$('.pay-logis').html('邮费'+list.postage+'元');
			$('.iteminfo_mktprice').hide();
			var goodsDetail = list.productparameter;
			 			
			var goodsname='<li>商品名称:&nbsp;' + list.goodsname + '</li>';
			
			if(list.isGoodsPoints == '1') {
				var str = '<li class="price iteminfo_price">' +
					'<dt>积分兑换</dt>' +
					'<dd><b class="sys_item_price">' + list.pointBuyAmount + '</b></dd>' +
					'</li>' +
					'<li class="price iteminfo_mktprice">' +
					'<dt>原价</dt>' +
					'<dd><em>¥</em><b class="sys_item_mktprice">' + list.goodPrice + '</b></dd>'
				'</li>' +
				'<div class="clear"></div>';
				$('.tb-detail-price').html(str);
				$(".tb-btn-buy").hide();
				$("#LikBasket").html("立即兑换");
				$("#J_AttrUL").html(goodsname);
				
			}
			else if(list.isGoodsPoints == '0'){
				var str2="";
				for(var i=0;i<goodsDetail.length;i++){
					str2+='<li>商品颜色:&nbsp;' + goodsDetail[i].color + '</li>'+
						  '<li>' + goodsDetail[i].goods_property_code + ':&nbsp;' + goodsDetail[i].property_item_name + '</li>'+
						  '<li>商品规格:&nbsp;'+goodsDetail[i].specification+'</li>'+
						  '<li>商品重量:&nbsp;'+goodsDetail[i].weight+'</li>';
				}
				$("#J_AttrUL").html(goodsname+str2);
			}
			//商品图片放大镜

			var picList = list.textPic;
			var html = '';
			for(var i = 0; i < picList.length; i++) {
				console.log(picList.length);
				html += '<li>' +
					'<div class="tb-pic tb-s40">' +
					'<a href="javascript:void(0)"><img src="' + picList[i] + '" mid="' + picList[i] + '" big="' + picList[i] + '"></a>' +
					'</div>' +
					'</li>';
				var html2 = '<a href="' + picList[0] + '">' +
					'<img src="' + picList[0] + '" alt="细节展示放大镜特效" rel="' + picList[0] + '" class="jqzoom" />' +
					'</a>';
				$('.tb-booth').html(html2);
				$("#thumblist").html(html);
			}
			jq();
			var imgList = list.imgUrls;
			for(var i = 0; i < imgList.length; i++){
				str = '<img src="'+imgList[i]+'" style="margin-bottom:20px;" />'
				$(".twlistNews").append(str);
			}
			//获得文本框对象
			var t = $("#text_box");
			//初始化数量为1,并失效减
			$('#min').attr('disabled', true);
			//数量增加操作
			$("#add").click(function() {
				t.val(parseInt(t.val()) + 1)
				if (parseInt(t.val()) != 1 && !( parseInt(t.val()) >= parseInt(list.stock))) {
					$('#min').attr('disabled', false);
				}else if( parseInt(t.val()) != 1 && parseInt(t.val()) >= parseInt(list.stock)){
					$('#add').attr('disabled', true);
				}
			})
				//数量减少操作
			$("#min").click(function() {
				t.val(parseInt(t.val()) - 1);
				if (parseInt(t.val()) <= 1) {
					$('#min').attr('disabled', true);
					$('#add').attr('disabled', false);
				}else{
					$('#add').attr('disabled', false);
				}
			})
		}
	});
	
	//获取默认地址
	$.ajax({
		type: "get",
		url: "/api/me/getDefaultAddress",
		async: true,
		data: {"token":token},
		dataType: "json",
		success:function(data){
			console.log(data.data);
			$('.prov').find("option:selected").text(data.data.province);
			$(".city").find("option:selected").text(data.data.city);
			$(".dist").find("option:selected").text(data.data.district);
		}
	});
	
	
	//商品规格
	$.ajax({
		type: "get",
		url: "/api/meetingroom/getGoodsStandard",
		async: true,
		data: {"goodsId": id},
		dataType: "json",
		success:function(data){
			var list = data.data;
			var str="";
			for(var i=0;i<list.length;i++){
				str +='<li class="sku-line">'+list[i].specification+'<i></i></li>';
				$(".specification").html(str);
			}
			standChoce();
			var specification = $(".specification .selected").text();
			$("#LikBasket").on("click",function(){
				addToShopCar(specification);
			})
		}
	});
	
	//商品评价
	$.ajax({
		type: "get",
		url: "/api/meetingroom/goodsEvaluates",
		async: true,
		data:{"pageSize":10,"page":1,"goodsId":id},
		dataType:"json",
		success:function(data){
			console.log(data);
			var list = data.data;
			for(var i=0;i<list.length;i++){
				str='<li class="am-comment">'+
						'<a href="">'+
							'<img class="am-comment-avatar" src="../images/hwbn40x40.jpg" />'+
						'</a>'+
						'<div class="am-comment-main">'+
							'<header class="am-comment-hd">'+
								'<div class="am-comment-meta">'+
									'<a href="#link-to-user" class="am-comment-author">'+list[i].userName+'</a>'+
									'评论于'+
									'<time datetime="">'+list[i].time+'</time>'+
								'</div>'+
							'</header>'+
							'<div class="am-comment-bd">'+
								'<div class="tb-rev-item " data-id="255776406962">'+
									'<div class="J_TbcRate_ReviewContent tb-tbcr-content ">'+list[i].content+'</div>'+
								'</div>'+
							'</div>'+
						'</div>'+
					'</li>';
				$(".am-comments-list-flip").append(str);
			}
		}
	});
	
	//加入购物车
	var num=$("#text_box").val();
	console.log(num);
	
	function addToShopCar(specification){
		$.ajax({
			type: "get",
			url: "/api/meetingroom/addToShopCar",
			async: true,
			data: {"goodsId":id,"num":parseInt($.trim($("#text_box").val())),"token":token,"specification":specification},
			dataType: "json",
			success:function(data){
//				getOrderAndCarNum();
//				console.log(data);
				window.location.reload()
			}
		});
	}
	
	

	
	//立即购买
	$(document).on("click","#LikBuy",function(){
		window.open("pay.html?id="+id);
		var name=$('.tb-detail-hd h1').html();
		var gg=$(".specification .selected").text();
		var num=$('#text_box').val();
		var postage=$('.pay-logis').html();
		var price=$('#price').html();
		localStorage.setItem("goodsname",name);
		localStorage.setItem("goodsgg",gg);
		localStorage.setItem("goodsnum",num);
		localStorage.setItem("goodspostage",postage);
		localStorage.setItem("goodsprice",price);
	})
//		

function jq() {
	$("#thumblist li").first().addClass("tb-selected");
	$(".jqzoom").imagezoom();
	$("#thumblist li a").click(function() {
		$(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");
		$(".jqzoom").attr('src', $(this).find("img").attr("mid"));
		$(".jqzoom").attr('rel', $(this).find("img").attr("big"));
	});
}
//收藏宝贝
function collectGoods(){
	$.ajax({
		type:"get",
		url:"/api/meetingroom/collectGoods",
		async:true,
		data:{"token":token,"goodsid":id,"isCollect":1,},
		dataType:"json",
		success:function(data){
			console.log(data);
		}
	});
}